package com.scj.vue3springboot.config;

import lombok.extern.slf4j.Slf4j;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * @Class CustomFilter
 * @Author ShiChaojie
 * @Email:scj0725@qq.com
 * 自定义的过滤器类，实现javax.servlet.Filter接口
 */
@WebFilter(urlPatterns = "/*")
@Slf4j
public class CustomFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
//        log.info("过滤器 - 初始化");
        Filter.super.init(filterConfig);
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//        log.warn("过滤器 - 请求处理之前");
        filterChain.doFilter(servletRequest, servletResponse); // 继续请求处理
//        log.warn("过滤器 - 请求处理之后");
    }

    @Override
    public void destroy() {
//        log.info("过滤器 - 销毁");
        Filter.super.destroy();
    }
}
